<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>取消监听</title>
</head>
<body>
<div id="app">
    <h1>{{ count }}</h1>
    <button @click="buttonClicked">点击+1</button>
</div>
<script type="module">
    import {createApp, ref, watch} from "../../../../../js/vue.esm-browser.js";

    const app = createApp({
        setup() {
            let count = ref(0)


            function buttonClicked() {
                count.value += 1

                if (count.value > 9) {
                    unwatch()
                }
            }

           let unwatch =  watch(
                count,
                function (value) {
                    console.log("count 的值发生了变化：" + value);
                },
            )

            return {
                count,
                buttonClicked,
            }
        }
    })

    app.mount("#app")
</script>
</body>
</html>